/*
 * @Description: 缺陷等级接口
 * @Author: Liu Zhiwang
 * @Date: 2021-04-13 20:19:54
 * @LastEditTime: 2021-09-28 14:02:33
 * @LastEditors: Huang Junjie
 */
import request from '@/utils/request'

// 查询列表信息
export function getListPage(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    url: query.unitCodeParams ? ('/jcwRepair' + query.unitCodeParams + '/defectLevel/') : '/jcwRepair/defectLevel/',
    method: 'GET',
    params: params
  })
}

// 根据id查询信息
export function getInfoById(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    url: query.unitCodeParams ? ('/jcwRepair' + query.unitCodeParams + `/defectLevel/getById`) : `/jcwRepair/defectLevel/getById`,
    method: 'GET',
    params: params
  })
}

// 新增/修改信息
export function addOrEditData(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    url: query.unitCodeParams ? ('/jcwRepair' + query.unitCodeParams + '/defectLevel/') : '/jcwRepair/defectLevel/',
    method: 'POST',
    data: params
  })
}

// 删除信息
export function deleteData(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    url: query.unitCodeParams ? ('/jcwRepair' + query.unitCodeParams + `/defectLevel/${params.id}`) : `/jcwRepair/defectLevel/${params.id}`,
    method: 'DELETE'
  })
}

// 上下改变排序
export function changeSort(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    url: query.unitCodeParams ? ('/jcwRepair' + query.unitCodeParams + '/defectLevel/move') : '/jcwRepair/defectLevel/move',
    method: 'POST',
    data: params
  })
}
